<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>饼状图</title>
		<script src="js/echarts.min.js"></script>
		<script src="js/jquery-3.4.0.min.js"></script>
	</head>
	<body>
		<div id="main" style="width: 600px;height: 400px;"></div>
		<script type="text/javascript">
			//基于dom初始化Echarts
			var myEchar = echarts.init(document.getElementById('main'));
			//数据加载之前可显示的内容
			myEchar.showLoading();
			//定义要查询的条件
			myUser = {"userid": 1}
			$.ajax({
				contentType: "application/json;charset=utf-8",
				type: "put",
				url: "http://localhost:3040/myUser/getEcharts",
				data: JSON.stringify(myUser),
				datalype: "json",
				success: function(res) {
					console.log(res) ;
					if (res) {
						myEchar.hideLoading() //关闭动画加载
						myEchar.setOption({
							  // xAxis: {
							  //   type: 'category',
							  //   data: ['can use',"can't use"]
							  // },
							  // yAxis: {
							  //   type: 'value'
							  // },
							  // series: [
							  //   {
							  //     data: res,
							  //     type: 'bar'
							  //   }
							  // ]
							title:{
								text: '系统用户分析',
								left: 'center'
							},
							tooltip: {
								trigger: ' item',
							},
							legend: {
								orient: 'vertical',
								left: 'left'
							},
							series: [{
								name:'user fenxi',
								type: 'pie',
								radius: '50%',
								data: res,
								emphasis: {
									itemStyle: {
										shadowBlur: 10,
										shadowOffsetX: 0,
										shadowColor: 'rgba(0, 0, 0,0.5)'}}
							}]
						});
					}
				},
				error: function(errorMsg) {
					alert("用户状态分析数据加载失败");
					myEchar.hideLoading();
				}
			});
		</script>
		</script>
	</body>
</html>
